"use strict";

class Car {
  private engine: string;

  constructor(engine: string) {
    this.engine = engine;
  }

  drive(distanceInMeter = 0) {
    console.log(
      `A car runs ${distanceInMeter}m
        powered by` + this.engine
    );
  }
}

class MotorCar extends Car {
  constructor(engine: string) {
    super(engine);
  }
}

class Jeep extends Car {
  constructor(engine: string) {
    super(engine);
  }

  drive(distanceInMeters = 100) {
    console.log(`jeep...`);
    return super.drive(distanceInMeters);
  }
}

const landRover: Car = new Jeep(`petrol`); //实现多态
landRover.drive(566);
